#include <iostream>
#include <map>
using namespace std;
map<string,string>father;
map<string,int>size;
string s1,s2;
int n,size1=0;
void init(string s1);
string get(string s);
void merge();
int main(){
	cin>>n;
	while(n--)
		merge();
	return 0;
}
void init(string s1){
	if(!father.count(s1)){
		father[s1]=s1;
		size[s1]=1;
	}
}
string get(string s){
	if(s==father[s]) return s;
	return father[s]=get(father[s]);
}
void merge(){
	cin>>s1>>s2;
	init(s1);init(s2);
	s1=get(s1);s2=get(s2);
	if(s1!=s2){
		father[s1]=s2;
		size[s2]+=size[s1];
	}
	size1=max(size[s1],size[s2]);
	cout<<size1<<endl;
}